{template 'web/_header'}
{template 'tabs'}
{if $operation == 'display'}
<form action="" method="post">
<div class="panel panel-default">
    <div class="panel-body table-responsive">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr>
                    <th style="width:20%;">ID</th>
                    <th style="width:20%;">标题</th>
                    <th style="width:40%;">状态</th>
                    <th style="width:20%;">操作</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                    <td>{$row['id']}</td>
                    <td>{$row['title']}</td>
                       	<td>
	                       	{if $row['status']==1}
	                        <span class='label label-success'>显示</span>
	                        {else}
	                        <span class='label label-danger'>隐藏</span>
	                        {/if}
                    	</td>
                    <td style="text-align:left;">
                        {ifp 'commission.ruanwen.view|commission.ruanwen.edit'}<a href="{php echo $this->createPluginWebUrl('commission/ruanwen', array('op' => 'post', 'id' => $row['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="{ifp 'commission.ruanwen.edit'}修改{else}查看{/if}"><i class="fa fa-edit"></i></a>{/if}
                        {ifp 'commission.ruanwen.delete'}<a href="{php echo $this->createPluginWebUrl('commission/ruanwen', array('op' => 'delete', 'id' => $row['id']))}"class="btn btn-default btn-sm" 
                                                     onclick="return confirm('确认删除此软文推广?')"
                                                     title="删除"><i class="fa fa-times"></i></a>{/if}
                    </td>
                </tr>
                {/loop}
                <tr>
                    <td colspan='6'>
                            {ifp 'commission.ruanwen.add'}
                          <a class='btn btn-default' href="{php echo $this->createPluginWebUrl('commission/ruanwen',array('op'=>'post'))}"><i class='fa fa-plus'></i> 添加软文推广</a>
                          {/if}
                    </td>
                </tr>
            </tbody>
        </table>
        {$pager}
    </div>
</div>
</form>
<script>
    require(['bootstrap'], function ($) {
        $('.btn').hover(function () {
            $(this).tooltip('show');
        }, function () {
            $(this).tooltip('hide');
        });
    });
</script>

{elseif $operation == 'post'}

<div class="main">
    <form     {ife 'commission.ruanwen' $ruanwen}action="" method="post"{/if} class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
        <input type="hidden" name="id" value="{$ruanwen['id']}" />
        <div class="panel panel-default">
            <div class="panel-heading">
                软文推广设置
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>标题</label>
                    <div class="col-sm-9 col-xs-12">
                            {ife 'commission.ruanwen' $ruanwen}
                        <input type="text" id='title' name="title" class="form-control" value="{$ruanwen['title']}" />
                           {else}
                        <div class='form-control-static'>{$ruanwen['title']}</div>
                        {/if}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">内容</label>
                    <div class="col-sm-9 col-xs-12">    
                        {ife 'commission.ruanwen' $ruanwen}
                            {php echo tpl_ueditor('description',$ruanwen['description'])}
                            {else}
                            <textarea id='description' style='display:none'>{$ruanwen['description']}</textarea>
                            <a href='javascript:preview_html("#description")' class="btn btn-default">查看内容</a>
                            {/if}
                            
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否显示</label>
                    <div class="col-sm-9 col-xs-12">
                            {ife 'commission.ruanwen' $ruanwen}
                        <label class='radio-inline'>
                            <input type='radio' name='status' value=1' {if $ruanwen['status']==1}checked{/if} /> 是
                        </label>
                        <label class='radio-inline'>
                            <input type='radio' name='status' value=0' {if $ruanwen['status']==0}checked{/if} /> 否
                        </label>
                            {else}
                             <div class='form-control-static'>{if empty($ruanwen['status'])}否{else}是{/if}</div>
                            {/if}
                    </div>
                </div>
                 <div class="form-group"></div>
            <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'commission.ruanwen' $ruanwen}
                            <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1"  />
                            <input type="hidden" name="token" value="{$_W['token']}" />
                        {/if}
                       <input type="button" name="back" onclick='history.back()' {ifp 'commission.ruanwen.add|commission.ruanwen.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
                    </div>
            </div>
                
                
            </div>
        </div>
      
    </form>
</div>

<script language='javascript'>
    function formcheck() {
        if ($("#title").isEmpty()) {
            Tip.focus("title", "请填写标题!");
            return false;
        }
        return true;
    }
</script>
{/if}
{template 'web/_footer'}